}
/**
+ * TODO: $s is not always a string per T218883
* @param string $s
* @return string
*/
function checkTitleEncoding( $s ) {
- Assert::parameterType( 'string', $s, '$s' );
+ if ( is_array( $s ) ) {
+ throw new MWException( 'Given array to checkTitleEncoding.' );
+ }
if ( StringUtils::isUtf8( $s ) ) {
return $s;
}
* Truncate a string to a specified number of characters, appending an optional
* string (e.g. for ellipsis).
*
- * This provides multibyte version of truncate() method of this class, suitable for truncation
- * based on number of characters, instead of number of bytes.
+ * This provides multibyte version of truncateForDatabase() method of this class,
+ * suitable for truncation based on number of characters, instead of number of bytes.
*
* If $length is negative, the string will be truncated from the beginning.
*
* @return string
*/
private function truncateInternal(
- $string, $length, $ellipsis, $adjustLength, $measureLength, $getSubstring
+ $string, $length, $ellipsis, $adjustLength, callable $measureLength, callable $getSubstring
) {
- if ( !is_callable( $measureLength ) || !is_callable( $getSubstring ) ) {
- throw new InvalidArgumentException( 'Invalid callback provided' );
- }
-
# Check if there is no need to truncate
if ( $measureLength( $string ) <= abs( $length ) ) {
return $string; // no need to truncate
* Checks that convertPlural was given an array and pads it to requested
* amount of forms by copying the last one.
*
- * @param array $forms Array of forms given to convertPlural
+ * @param array $forms
* @param int $count How many forms should there be at least
- * @return array Padded array of forms or an exception if not an array
+ * @return array Padded array of forms
*/
protected function preConvertPlural( /* Array */ $forms, $count ) {
- while ( count( $forms ) < $count ) {
- $forms[] = $forms[count( $forms ) - 1];
- }
- return $forms;
+ return array_pad( $forms, $count, end( $forms ) );
}
/**
* @param array $query Optional URL query parameter string
* @param bool $atend Optional param for specified if this is the last page
* @return string
+ * @deprecated since 1.33, use SpecialPage::viewPrevNext()
+ * instead.
*/
public function viewPrevNext( Title $title, $offset, $limit,
array $query = [], $atend = false